package com.atguigu05.method_more._04recursion;

/**
 * @author 尚硅谷-宋红康
 * @create 16:57
 */
public class RecursionTest {
    public static void main(String[] args) {
        RecursionTest re = new RecursionTest();
        System.out.println(re.getSum(100));
        System.out.println(re.getMul(10));
    }

    /**
     * 计算1-n数的和
     * @param num
     * @return
     */
    public int getSum(int num){
        if (num == 1) {
            return 1;
        }
        return getSum(num-1)+num;
    }

    public int getMul(int num){
        if (num == 1 ){
            return 1;
        }
        return getSum(num-1)*num;
    }


}
